//删除按钮
function deleteProduct() {
    let deleteBtns = document.querySelectorAll('.delete-btn');
    for (let i = 0; i < deleteBtns.length; i++) {
        deleteBtns[i].onclick = function () {
            //调用删除接口
            let uid = localStorage.getItem('uid')
            let token = localStorage.getItem('token')
            // pid  按钮上 属性里面
            let pid = this.getAttribute('data-id')
            let url = 'http://jx.xuzhixiang.top/ap/api/goods/goods-delete.php'
            axios.get(url, {
                params: {
                    uid, token, pid
                }
            }).then(res => {
                console.log(res.data);
                this.parentNode.remove()
            })
        }
    }
}

//发布商品
function publishProduct() {
    let ipts = document.querySelectorAll('#send input')
    ipts[4].onclick = function () {
        let pname = ipts[0].value
        let pprice = ipts[1].value
        let pimg = ipts[2].value
        let pdesc = ipts[3].value
        let uid = localStorage.getItem('uid')

        let pAPI = 'http://jx.xuzhixiang.top/ap/api/goods/goods-add.php'
        axios.get(pAPI, { params: { pname, pprice, pimg, pdesc, uid } })
            .then(res => {
                console.log(res.data);
            })


    }
}